<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/cat.svg" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <meta
      name="viewport"
      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0 viewport-fit=cover"
    />
    <title>%VITE_APP_TITLE%</title>
    <link rel="stylesheet" href="%VITE_BASE_URL%css/animate.min.css" />
    <script src="https://img.life.cntaiping.com/cms/js/fastclick.min.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>

    <!-- 微信 sdk -->
    <script>
      var ua = window.navigator.userAgent.toLowerCase()
      if (ua.match(/micromessenger/i) === 'micromessenger') {
        if (ua.match(/wxwork/i) === 'wxwork') {
          document.write(
            '<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"><\/script>'
          )
          document.write(
            '<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"><\/script>'
          )
        } else {
          document.write(
            '<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"><\/script>'
          )
        }
      }
    </script>

    <!-- 强制禁止用户修改微信客户端的字体大小 -->
    <script>
      ;(function () {
        if (
          typeof WeixinJSBridge == 'object' &&
          typeof WeixinJSBridge.invoke == 'function'
        ) {
          handleFontSize()
        } else {
          if (document.addEventListener) {
            document.addEventListener(
              'WeixinJSBridgeReady',
              handleFontSize,
              false
            )
          } else if (document.attachEvent) {
            document.attachEvent('WeixinJSBridgeReady', handleFontSize)
            document.attachEvent('onWeixinJSBridgeReady', handleFontSize)
          }
        }
        function handleFontSize() {
          // 设置网页字体为默认大小
          WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
          // 重写设置网页字体大小的事件
          WeixinJSBridge.on('menu:setfont', function () {
            WeixinJSBridge.invoke('setFontSizeCallback', { fontSize: 0 })
          })
        }
      })()
    </script>

    <script>
      if ('addEventListener' in document) {
        document.addEventListener(
          'DOMContentLoaded',
          function () {
            FastClick.attach(document.body)
            // 解决ios11以上输入框难获取焦点的问题
            FastClick.prototype.focus = function (targetElement) {
              var length
              var isIphone = !!window.navigator.userAgent.match(
                /(iPhone\sOS)\s([\d_]+)/
              )
              var isIpad =
                !!window.navigator.userAgent.match(/(iPhone)/) &&
                !!window.navigator.userAgent.match(/(OS)\s([\d_]+)/)
              var deviceIsIos = isIphone || isIpad
              if (
                deviceIsIos &&
                targetElement.setSelectionRange &&
                targetElement.type.indexOf('date') !== 0 &&
                targetElement.type !== 'time' &&
                targetElement.type !== 'month' &&
                targetElement.type !== 'email'
              ) {
                length = targetElement.value.length
                targetElement.setSelectionRange(length, length)
                targetElement.focus()
              } else {
                targetElement.focus()
              }
            }
          },
          false
        )
      }
    </script>
  </body>
</html>
